import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';

@Injectable()
export class AppRouteGuardService {

  constructor(private router: Router) { }

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    // 返回值 true: 跳转到当前路由 false: 不跳转到当前路由
    // 当前路由名称
    const pathURL = route.routeConfig.path;
    console.log(route.routeConfig.path);
    // nextRoute: 设置需要路由守卫的路由集合
    alert('path:' + pathURL);
    return true;
  }
}
